package cn.ekuma.epos.bean.util.sale;

import cn.ekuma.epos.bean.util.PaymentInfoHelper;

import com.openbravo.bean.PaymentInfo;
import com.openbravo.bean.PaymentInfoCash;
import com.openbravo.bean.PaymentInfoMagcard;
import com.openbravo.bean.shard.I_WarpEntity;
import com.openbravo.format.Formats;
import com.openbravo.pos.bean.PaymentInfoTicket;

public class PaymentWarp implements I_WarpEntity<PaymentInfo>{
	PaymentInfo p;
	
	public PaymentWarp(PaymentInfo p){
		this.p=p;
	}
	
	public String printTotal() {
        return PaymentInfoHelper.printTotal(p);
    }

    public String printPaid() {
    	if(p.getName().equalsIgnoreCase("cash"))
    		return PaymentInfoHelper.printPaid((PaymentInfoCash)p);
    	return "not cash pay";
    }
    
    public String printChange() {
    	if(p.getName().equalsIgnoreCase("cash"))
           return PaymentInfoHelper.printChange((PaymentInfoCash) p);
    	return "no cash pay";
    }

    // Especificas
    public static String printPaperTotal(PaymentInfoTicket p) {
        // En una devolucion hay que cambiar el signo al total
        return Formats.CURRENCY.formatValue(new Double(-p.getM_dTicket()));
    }
	
	public String getName(){
		return p.getName();
	}
	
    public String printCardNumber() {
    	if(p instanceof PaymentInfoMagcard)
    		return ((PaymentInfoMagcard)p).printCardNumber();
        return "no card pay";
    }
    public String printExpirationDate() {
    	if(p instanceof PaymentInfoMagcard)
    		return ((PaymentInfoMagcard)p).printExpirationDate();
    	return "no card pay";
    }
    public String printAuthorization() {
    	if(p instanceof PaymentInfoMagcard)
    		return ((PaymentInfoMagcard)p).printAuthorization();
    	return "no card pay";
    }
    public String printTransactionID() {
    	if(p instanceof PaymentInfoMagcard)
    		return ((PaymentInfoMagcard)p).printTransactionID();
    	return "no card pay";
    }

	@Override
	public PaymentInfo getWarpBean() {
		return p;
	}
}
